package net.jarang.sourcegen;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


public class SourceGeneratorMain {
	private static final Log log = LogFactory.getLog(SourceGeneratorMain.class);
	protected List<Generator> generators = new ArrayList<Generator>();

	private static final String RESOURCE_NAME = "template-saleoffline.properties";
	
	public void addGenerators(Generator generator) {
		generators.add(generator);
	}
	
	public void start() {
		System.out.println("started.....");
		if(generators == null || generators.size() == 0) {
			log.info("There is no the generator for executing.");
			return;
		}
		
		for (Generator generator : generators) {
			generator.generate();
			System.out.println("executed " + generator.getType());
		}
		System.out.println("finished.....");
	}
	
	public static void main(String[] args) {
		String[] targets = {"sqlmap", "model", "dao", "search", "controller", "jsp-list", "jsp-form", "jsp-view"};
		SourceGeneratorMain executor = new SourceGeneratorMain();
		
		for (String target : targets) {
			executor.addGenerators(new Generator(RESOURCE_NAME, target));
		}
		executor.start();
	}
}
